<?php
	$ano = $_POST['ano'];
	
	include 'open-connection.php';
	
	// Performing SQL query
	$query = 	"SELECT MONTHNAME(FECHA) AS MES, P.idpatologia AS ID, P.nombre AS NOMBRE, COUNT(C.idconsulta) AS CONSULTAS
FROM CONSULTA C 
INNER JOIN PATOLOGIA P ON C.idpatologia = P.idpatologia 
WHERE YEAR(FECHA) = $ano 
GROUP BY MONTH(FECHA), P.idpatologia ORDER BY C.fecha";
	$result = mysql_query("SET lc_time_names = 'es_VE';") or die('Query failed: ' . mysql_error());
	$result = mysql_query($query) or die('Query failed: ' . mysql_error());
	
	while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
		$arr[] = $line;
	}

	include 'close-connection.php';
	echo json_encode($arr);
?>